const express = require('express')
const passport = require('../../middlewares/jwtAuthStrategy')
const router = express.Router()
const {
  getAllTasksHandler,
  getAllSubTasksHandler,
  getTaskHandler,
  getSubTaskHandler,
  postNewTaskHandler,
  postNewSubTaskHandler,
  putTasksHandler,
  patchAllTasksHandler,
  patchTaskHandler,
  deleteTaskHandler,
} = require('../../controllers/tasksController')

router.get('/', passport.authenticate('jwt', {session: false}), getAllTasksHandler)

router.get('/main', getAllSubTasksHandler)

router.get('/:id', getTaskHandler)

router.get('/main-subtasks/:id', getSubTaskHandler)

router.post('/new-tasks', postNewTaskHandler)

router.post('/new-subtask/:id', postNewSubTaskHandler)

router.put('/:id', putTasksHandler)

router.patch('/', patchAllTasksHandler)

router.patch('/:id', patchTaskHandler)

router.delete('/:id', deleteTaskHandler)

module.exports = router
